package com.pay.cloud.fragment;

import android.content.Intent;
import android.os.Bundle;

import com.pay.cloud.DataFactory;

import static com.pay.cloud.fragment.TipFragment.TipType.SUCCESS;

public class IpCableStaticFragment extends AbstractIpFragment {

    @Override
    protected String defaultIps() {
        return DataFactory.getDataStore().getCableIp();
    }

    @Override
    protected void applyIps(String ips) {
        Bundle bundle = new Bundle();
        bundle.putSerializable("STATIC_IP", ips.split("\\;"));
        Intent intent = new Intent("com.snstar.networkparameters.ETHSETINGS");
        intent.putExtras(bundle);
        getContext().sendBroadcast(intent);

        getContext().sendBroadcast(new Intent("com.snstar.networkparameters.ETH_OPEN"));

        DataFactory.getDataStore().setCableIp(ips);

        setMainFragment(new TipVerticalFragment(SUCCESS, "已切换至使用静态IP"));
    }

    @Override
    protected void popBackStack() {
        setMainFragment(new ConnectFragment());
    }

}
